<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>阶乘</title>
</head>

<body>

</body>
<script>
    /*     const num = (n) => {
            if (n === 1) {
                return 1
            }
            return n * num(n - 1)
        }
        console.log(num(3)); */

    const num = (n, total) => {
        if (n === 1) {
            return total
        }
        return num(n - 1, n * total)
    }
    console.log(num(3,1));
</script>

</html>